#!/usr/bin/perl
#
#
while($line=<STDIN>) {
	chomp($line);
	($param,$value) = split(/\s+/,$line);
	$param=~s/relOrder://g;
	@f = split(/-/,$param);
	foreach $e (@f) {
		if($e=~/^[A-Z]+$/) {
			$type = $e;
			last;
		}
	}
	
	$key = join('-',sort(@f));

	if((!defined $info->{$type}->{$key}) || $value>$info->{$type}->{$key}->{'value'}) {
		$info->{$type}->{$key}->{'relOrder'} = $param;
		$info->{$type}->{$key}->{'value'} = $value;
	}
}

foreach $type (keys %$info) {
	print "Type:$type\n";
	foreach $key (sort {$info->{$type}->{$b}->{'value'}<=>$info->{$type}->{$a}->{'value'}} keys %{$info->{$type}}) {
		print "\t".$info->{$type}->{$key}->{'relOrder'}."\t".$info->{$type}->{$key}->{'value'}."\n";
	}
}

